<script setup lang="ts">
import { ref, onMounted, defineEmits } from 'vue'
import { companyListApi } from '@/api/path'

defineProps<{ modelValue: any }>()
const emit = defineEmits<{
  (e: 'update:modelValue', val: any): void
}>()

const list = ref<any[]>([])
async function queryList() {
  const res: any = await companyListApi()
  list.value = (res.data || []) as any[]
}

onMounted(() => {
  queryList()
})
</script>

<template>
  <el-select v-bind="$attrs" clearable :modelValue="modelValue" filterable placeholder="请选择公司" @change="(val: any) => emit('update:modelValue', val)">
    <el-option
      v-for="(item, index) in list"
      :key="index"
      :label="item.companyName + ' - ' + item.username"
      :value="item.userID"
    />
  </el-select>
</template>

<style lang="scss" scoped></style>
